var ScrollY = {init: function (scrollCon, scrollBar, maskW, maskH, hy, hh) {
    console.log(scrollCon, scrollBar, maskW, maskH, hy, hh);
    var iniTime = 0;
    var nowTime = 0;
    var scrollY = {};
    var con, bar, scrollMaskWidth, scrollMaskHeight, hitY, hitH, conWidth, conHeight, iniY, tempY;
    con = scrollCon;
    bar = scrollBar;
    scrollMaskWidth = maskW;
    scrollMaskHeight = maskH;
    hitY = hy;
    hitH = hh;
    conWidth = con.getBounds().width;
    conHeight = con.getBounds().height;
    scrollY.addEvent = function () {
        stage.addEventListener("stagemousedown", scrollmousedownHandle);
        if (bar) {
            bar.addEventListener("tick", barTickHandle)
        }
    };
    scrollY.removeEvent = function () {
        stage.removeEventListener("stagemousedown", scrollmousedownHandle)
    };
    function scrollmousedownHandle(evt) {
        evt.preventDefault();
        iniY = evt.stageY;
        tempY = evt.stageY;
        if (bar) {
            bar.alpha = 1
        }
        iniTime = new Date().getTime();

        if ((con.y <= 0 && con.y >= (-conHeight + scrollMaskHeight)) && (evt.stageY > hitY && evt.stageY < hitH)) {
            stage.addEventListener("stagemousemove", scrollmousemoveHandle);
            stage.addEventListener("stagemouseup", scrollmouseupHandle)
        }
    }

    function scrollmousemoveHandle(evt) {

        evt.preventDefault();
        con.mouseEnabled = false;
        if (evt.stageY < tempY - 10) {
            tempY = evt.stageY;
            con.y -= 10;
            if (bar) {
                bar.y = -(scrollMaskHeight - bar.getBounds().height) * con.y / (conHeight - scrollMaskHeight)
            }
        }
        if (evt.stageY > tempY + 10) {
            tempY = evt.stageY;
            con.y += 10;
            if (bar) {
                bar.y = -(scrollMaskHeight - bar.getBounds().height) * con.y / (conHeight - scrollMaskHeight)
            }
        }
    }

    function scrollmouseupHandle(evt) {
        evt.preventDefault();
        nowTime = new Date().getTime();
        if (Math.abs(evt.stageY - iniY) > 10) {
            if ((con.y <= 0 && con.y >= (-conHeight + scrollMaskHeight))) {
                if (evt.stageY > iniY && (nowTime - iniTime) < 400) {
                    createjs.Tween.get(con).to({y: con.y + (400)}, 300).call(checkConY1)
                }
                if (evt.stageY < iniY && (nowTime - iniTime) < 400) {
                    createjs.Tween.get(con).to({y: con.y - (400)}, 300).call(checkConY2)
                }
            } else {
                if (evt.stageY < iniY && (con.y > 0 || con.y < (-conHeight + scrollMaskHeight))) {
                    createjs.Tween.get(con).to({y: -conHeight + scrollMaskHeight}, 300)
                } else {
                    createjs.Tween.get(con).to({y: 0}, 300)
                }
            }
        }
        iniY = evt.stageY;
        tempY = evt.stageY;
        iniTime = new Date().getTime();
        stage.removeEventListener("stagemousemove", scrollmousemoveHandle);
        stage.removeEventListener("stagemouseup", scrollmouseupHandle);
        setTimeout(function () {
            con.mouseEnabled = true
        }, 500);
        if (bar) {
            bar.alpha = 0.5
        }
    }

    function checkConY2() {
        if (con.y < (-conHeight + scrollMaskHeight)) {
            console.log("向上过度");
            createjs.Tween.get(con).to({y: -conHeight + scrollMaskHeight}, 300)
        }
    }

    function checkConY1() {
        if (con.y > 0) {
            console.log("向下过度");
            createjs.Tween.get(con).to({y: 0}, 300)
        }
    }

    function barTickHandle(evt) {
        bar.y = -(scrollMaskHeight - bar.getBounds().height) * con.y / (conHeight - scrollMaskHeight)
    }

    return scrollY
}};